import dayjs from 'dayjs'

export const TIME_FORMAT = 'MM-DD HH:mm'
export const DATE_FORMAT = 'YYYY-MM-DD'

export const getNowTime = () => {
  return dayjs().format(TIME_FORMAT)
}

export const getLastWeekRange = (): [start: string, end: string] => {
  const end = dayjs().format(DATE_FORMAT)
  const start = dayjs().subtract(7, 'day').format(DATE_FORMAT)
  return [start, end]
}

export const getLastMonthRange = (): [start: string, end: string] => {
  const end = dayjs().format(DATE_FORMAT)
  const start = dayjs().subtract(1, 'month').format(DATE_FORMAT)
  return [start, end]
}

export const getLastYearRange = (): [start: string, end: string] => {
  const end = dayjs().format(DATE_FORMAT)
  const start = dayjs().subtract(1, 'year').format(DATE_FORMAT)
  return [start, end]
}